def GetMainDirection(u:float, v:float, SCs:[list,list,list,...], Ps:[int,int]):
    '''
        功能：求参数多项式曲面上一点处的最大最小主曲率及其所在(用单位矢量表示)的主方向。
        输入参数：u,v-参数点；
                  SCs-幂基参数多项式曲面的系数矢量。
                  Ps-分别为沿u、v数据点数。 
        调用函数：GetSurDerivat-求曲面上一点的偏导矢。
        输出参数：k1、k2-由曲面上一点(u,v)的最大最小主曲率；
                  m1、m2-k1、k2所在(用单位矢量表示)的主方向。
    '''
    import math
    pts = []
    for rank in ((0,1),(1,0),(0,2),(1,1),(2,0)):
        p1 = GetSurDerivat(v, u, *rank, 1, SCs, Ps)
        p2 = GetSurDerivat(v, u, *rank, 2, SCs, Ps)
        pts.append((p1[0], p2[1], p1[1]))
    pux,puy,puz = pts[0]; pvx,pvy,pvz = pts[1]
    puux,puuy,puuz = pts[2]; puvx,puvy,puvz = pts[3]; pvvx,pvvy,pvvz = pts[4]

    ulenth = math.sqrt(pux*pux+puy*puy+puz*puz)
    vlenth = math.sqrt(pvx*pvx+pvy*pvy+pvz*pvz)
    UVAngle = 180*math.acos((pux/ulenth)*(pvx/vlenth)+(puy/ulenth)*(pvy/vlenth)+ \
                (puz/ulenth)*(pvz/vlenth))/math.pi
    pnx = puy*pvz-puz*pvy; pny = puz*pvx-pux*pvz; pnz = pux*pvy-puy*pvx
    lenth = math.sqrt(pnx*pnx+pny*pny+pnz*pnz)
    pnx /= lenth; pny /= lenth; pnz /= lenth
    E = pux*pux+puy*puy+puz*puz
    F = pux*pvx+puy*pvy+puz*pvz
    G = pvx*pvx+pvy*pvy+pvz*pvz
    L = pnx*puux+pny*puuy+pnz*puuz
    M = pnx*puvx+pny*puvy+pnz*puvz
    N = pnx*pvvx+pny*pvvy+pnz*pvvz
    delta = math.sqrt((G*L-E*N)*(G*L-E*N)-4*(E*M-F*L)*(F*N-G*M))

    assert delta, "该点是脐点，两个主曲率相同，所有方向都是主方向；\n"+
                    "所有方向的法曲率相同，都是主曲率。"

    temp1 = [E*N-2*F*M+G*L, delta, 2*(E*G-F*F)]
    k1 = (temp1[0]+temp1[1])/temp1[2]; k2 = (temp1[0]-temp1[1])/temp1[2]

    mvs = [None]*2
    temp2 = [G*L-E*N, delta, 2*(F*N-G*M)]
    tanpha = [(temp2[0]+temp2[1])/temp2[2], (temp2[0]-temp2[1])/temp2[2]]
    for i in range(2):
        mx = pux+tanpha[i]*pvx; my = puy+tanpha[i]*pvy; mz = puz+tanpha[i]*pvz
        lenth = math.sqrt(mx*mx+my*my+mz*mz)
        mx /= lenth;  my /= lenth;  mz /= lenth
        mvs[i] = (mx,my,mz)
    m1,m2 = mvs

    return k1,k2,m1,m2

if __name__ == '__main__':
    ...